package com.qbao.newim.qbnetwork;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

import com.qbao.newim.network.JniNetCallBack;
import com.qbao.newim.network.JniNetWork;

public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        // Example of a call to a native method
        JniNetWork jni_network = new JniNetWork();
        JniNetCallBack net_callback = new JniNetCallBack();

        String str;
        str = "create = " + jni_network.create() + "\n";
        str += "InitCallBack = " + jni_network.InitCallBack(net_callback) + "\n";
        str += "Connect = " + jni_network.Connect("192.168.131.41", 8001, true) + "\n";
        byte[] ss_encrypt = new byte[17];
        for (int i = 0; i < 17; i++) {
            ss_encrypt[i] = (byte) i;
        }
        ss_encrypt =  jni_network.EncryptBody(ss_encrypt, ss_encrypt.length);
        str += "EncryptBody--->" + ss_encrypt + "\n";

        byte[] ss_cookie = new byte[17];
        for (int i = 0; i < 17; i++) {
            ss_cookie[i] = (byte) i;
        }
        ss_cookie = jni_network.EncryptCookie(ss_cookie, ss_cookie.length);
        str += "EncryptCookie--->" + ss_cookie + "\n";

        str += "当前微秒时间--->" + jni_network.GetMicrosecond();

        ((TextView)findViewById(R.id.sample_text)).setText(str);
    }
}
